home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
dcg301up
/
merchant.scr
< prev
next >
Wrap
Text File
|
1993-05-24
|
12KB
|
377 lines
!
! Default merchant script..
!
! (c) DC Software, 1993
!
! Pending Enhancements
!
! - I need to create a voice file (.VFL) with voices for this script.
! Look at the 'voice()' entries to see what voices it would play if
! they were available. These voices could even be placed in the
! system's voice file (DCSOUNDS.VFL) in which case the voice command
! should read 'voice( xxxx, 1000 )'.
!
!------------------------------------------------------------------------!
:@TALK ! Talk to the character !
!------------------------------------------------------------------------!
! First, say hello.. !
if NPC.V0 > 0 then
writeln( "Hello ", player.name, ". What brings you back?" );
else
writeln( "Welcome to ", npc.name, ". How may I help you?" );
endif;
! Now, set some variables..
NPC.V0 = 1; ! From know on, remember we've been here
L1 = 0; ! No items have been SOLD to the player
L2 = 0; ! No items have been BOUGHT from the player
! Then start a loop and show a menu..
:LOOP
L3 = select( "Buy", "Sell", "Identify", "Talk", "Bye" );
on L3 goto BUY, SELL, GETINFO, CHAT;
! ESCape and BYE get's us out of here..
:CSTOP
if L1 = 0 and L2 = 0 then
writeln( "Next time buy something!" );
else
writeln( "It's been a pleasure doing business with you!" );
endif;
STOP;
!-------------------------------------------------!
! Player want's to buy something from us.. !
!-------------------------------------------------!
:BUY
L3 = select$( NPC );
if L3 < 0 goto LOOP;
if NPC.BP.VALUE >= GROUP.GOLD then
writeln( "You don't have enough money!");
voice( "Broke" );
else
if npc.bp.type = FOOD and npc.bp.class = NONE then
L10 = 255 - group.food; ! Max food we can carry !
if L10 < npc.bp.count then
L11 = npc.bp.count - L10;
writeln( "{You have to carry ", L11, " in your backpack}" );
inc( group.food, L10 );
copy( npc.bp, player, L11 ); ! Put L11 foods in the backpack !
if failure then
L12 = failure - 1;
writeln( "{The excess merchandize is placed on the floor!}" );
drop( npc.bp, -L12 ); ! Negative count means "drop a copy" !
endif;
else
inc( group.food, npc.bp.count );
endif;
else
L12 = npc.bp.count;
copy( NPC.BP, PLAYER );
if failure then
! Value of failure is # that DID NOT get moved (+1) !
L11 = failure - 1;
if L12 > 1 then
if L11 < L12 then
writeln( "You can only carry {", L11, "} of them!" );
else
writeln( "You can't carry them!" );
endif;
else
writeln( "You can't carry it!" );
endif;
writeln( "The ", npc.bp.name, " is ON THE FLOOR!" );
if npc.x = player.x then
L13 = npc.x;
L14 = player.y + sgn(npc.y - player.y);
else
L13 = player.x + sgn(npc.x - player.x);
L14 = npc.y;
endif;
drop( npc.bp, -L11, L13, L14 ); ! Leave a copy (-) under the PLAYER !
endif;
endif;
dec ( GROUP.GOLD, NPC.BP.VALUE );
inc ( L1 ); ! Sold 1 item to the PLAYER !
writeln( "SOLD: ", NPC.BP.COUNT, " ", NPC.BP.NAME, " for ", $NPC.BP.VALUE );
voice( "Sold" );
endif;
goto BUY;
!
! Player want's to sell something to us..
!
:SELL
L3 = select$2( PLAYER, matching ); ! Shows only thing's that I might want to buy !
if L3 < 0 then
if L3 = -2 then ! No items in the player's backpack !
if L2 > 0 then
writeln( "You have no more items to sell." );
voice( "NonLeft" );
else
writeln( "You have no items to sell." );
voice( "NoItems" );
endif;
endif;
if L3 = -3 then ! No items of the type(s) I sell in the backpack !
if L2 > 0 then
writeln( "You have no more items that I would like to buy." );
voice( "NonLeft" );
else
writeln( "You have no items that I would like to buy." );
voice( "NoItems" );
endif;
endif;
goto LOOP;
endif;
! Buy an item at half price (it's used) !
if player.bp.count > 1 then
L10 = getnum( "Sell how many?", 0, player.bp.count );
else
L10 = 1;
endif;
if L10 > 0 then
if player.bp.type = FOOD and player.bp.class = POISON then
writeln( "Sorry. This food is poisoned. Anything else?" );
goto SELL;
endif;
L4 = (PLAYER.BP.VALUE+1) / 2; ! Price paid for the item.
if L10 > 1 then
writeln( "Here is ", $L4, " for each of your ", L10, " ", PLAYER.BP.NAME, "s" );
else
writeln( "Here is ", $L4, " for your ", PLAYER.BP.NAME );
endif;
voice( "Bought" );
inc( group.gold, L4*L10 ); ! Pay the player for the items
inc( L2 ); ! Bought 1 item from the player !
! Now, see if we have an exact or approximate match
for L11 = 0 to 15 do
setbp( npc, L11 );
if npc.bp.count > 0 and
npc.bp.name = player.bp.name and
npc.bp.type = player.bp.type and
npc.bp.class = player.bp.class and
npc.bp.value = player.bp.value goto REMOVEIT;
endfor;
! Merchant does not have an identical item, so we will copy 1 (one)
! item into the backpack for later resale
!
! Note: The assumption is that the 'value' field contains the
! UNIT value. If the player had 20 items, we paid 20 x value, so
! we keep 1 copy and sell each for 'value' amount.
copy( player.bp, npc, 1 );
:REMOVEIT
if L10 < player.bp.count then
dec( player.bp.count, L10 ); ! Remove the items we sold
else
player.bp.count = 0; ! Zap the items
endif;
else
writeln( "Maybe another item? <ESC> for go back" );
endif;
goto SELL;
!
! Player want's to know about some of the items he has..
!
:GETINFO
writeln( "Let me see.. What do you wish to identify?" );
L3 = select$2( PLAYER, matching ); ! Item's I know about !
if L3 < 0 then
if L3 = -2 then ! No items in the player's backpack !
if L2 > 0 then
writeln( "You have no more items!" );
voice( "NonLeft" );
else
writeln( "Your backpack is empty!" );
voice( "NoItems" );
endif;
endif;
if L3 = -3 then ! No items of the type(s) I sell in the backpack !
if L2 > 0 then
writeln( "There are no other items I can identify!" );
voice( "NonLeft" );
else
writeln( "There are no items that I can identify!" );
voice( "NoItems" );
endif;
endif;
goto LOOP;
endif;
! Identify the selected item
L4 = (player.bp.value+7) / 8;
writeln( "The fee is ", $L4, ". Do you pay it?" );
L11 = select( "Yes", "No" );
if L11 = 0 then ! Yes !
if group.gold < L4 then
writeln( "You don't have enough money!" );
voice( "Broke" );
goto LOOP;
endif;
gosub DESCRIBE;
writeln( "What name do you want to give it? <ESC>=none" );
L3 = getstr();
if L3 = -2 then ! -1 = <ESC>, -2 = Any string not in the list (No List) !
player.bp.name = S0;
else
writeln( "ok" );
endif;
dec( group.gold, L4 );
else
writeln( "Maybe another item? <ESC> to go back" );
endif;
goto GETINFO;
!-------------------------------------------------------------------!
! Describe an item (player's BP) !
!-------------------------------------------------------------------!
:DESCRIBE
if player.bp.count < 0 then
writeln( "I don't know what you're talking about" );
return;
endif;
write( "Name: ", player.bp.name, ", Type: ", player.bp.type );
if player.bp.type = FOOD or player.bp.type = POTION then
if player.bp.class then
write( ", Class: ", player.bp.class );
if player.bp.class <> CURE then
write( ", Units: ", player.bp.units );
endif;
else
write( ", it has no special properties" );
endif;
elsif player.bp.type = WEAPON then
write( ", Class: ", player.bp.class,
", Hands: ", player.bp.hands,
", Range: ", player.bp.range,
", Damage: ", player.bp.damage );
if player.bp.ammoneeded then
write( ", Needs ammo type: ", player.bp.ammo_type );
endif;
elsif player.bp.type = AMMO then
write( ", Ammo Type: ", player.bp.ammotype );
if player.bp.traptype then
write( ", Poisoned" );
endif;
if player.bp.damage then
write( ", Extra Damage: ", player.bp.damage );
endif;
elsif player.bp.type = ARMOR or player.bp.type = SHIELD then
write( ", Armor Class: ", player.bp.ac );
if player.bp.cursed then
write( " Cursed!" );
endif;
elsif player.bp.type = AMULET or player.bp.type = RING or player.bp.type = GEMS then
if player.bp.class then
write( ", Class: ", player.bp.class );
write( ", Charges: ", player.bp.charges );
if player.bp.class <> CURE then
write( ", Units: ", player.bp.units );
if player.bp.permanent then
write( ", Permanent!" );
else
write( ", Temporary" );
endif;
endif;
if player.bp.cursed then
write( ", Cursed!" );
endif;
endif;
elsif player.bp.type = SCROLL then
write( ", Class: ", player.bp.class );
elsif player.bp.type = STAFF then
write( ", Class: ", player.bp.class, ", Charges: ", player.bp.charges );
elsif player.bp.type = CHEST then
if player.bp.locktype then
write( ", Locked!" );
if player.bp.traptype = 0 then
write( ", no traps" );
elsif player.bp.traptype = 1 then
write( ", poison trap" );
else
write( ", bomb damage: ", player.bp.traptype );
endif;
endif;
! elsif player.bp.type = KEYS then
! nothing special about it
! elsif player.bp.type = BOOK then
! nothing special about it
! elsif player.bp.type = GOLDSACK then
! nothing special about it
! elsif player.bp.type = TORCH then
! nothing special about it
! elsif player.bp.type = LANTERN then
! nothing special about it
! elsif player.bp.type = ROPE then
! nothing special about it
! elsif player.bp.type = HOOKS then
! nothing special about it
! elsif player.bp.type = MIRROR then
! nothing special about it
! elsif player.bp.type = SIGN then
! nothing special about it
elsif player.bp.type = VEHICLE then
write( ", Class: ", player.bp.class );
! else
! user defined type?
endif;
if player.bp.weight > 1 and player.bp.weight < 256 then
write( ", Weight: ", player.bp.weight );
endif;
writeln( "." );
return;
!
! Handle conversation..
!
:CHAT
writeln( "What would you like to talk about?" );
:CHAT1
L3 = getstr("Name","Buy","Sell","Credit","Job","Bye");
if L3 = -1 then
writeln( "Ok." );
goto LOOP; ! Pressed ESCape !
endif;
! First, see if the keyword typed is in the character's text block !
if dotext( S0 ) then
if L3 = 5 then
STOP;
endif;
goto CHAT1;
endif;
! It didn't, so try the predefined ones..
on L3 goto CNAME, BUY, SELL, CCREDIT, CJOB, CSTOP;
! Nope, try a 'DEFAULT' line
if not dotext( "DEFAULT" ) then
writeln( "I don't know anything about that!" );
endif;
goto CHAT1;
:CNAME writeln( "My name is ", NPC.name, "." ); GOTO CHAT1;
:CCREDIT writeln( "No credit sales, sorry!" ); GOTO CHAT1;
:CJOB writeln( "I {buy} and {sell} things!" ); GOTO CHAT1;
! Feel free to expand on this list.. !